package com.easpeed.comon.bean

import android.app.Application
import android.os.Bundle
import android.preference.PreferenceManager
import com.easpeed.comon.memorycache.CommonMemoryCache
import com.easpeed.comon.utils.ActivityLifecycleHelper
import com.easpeed.comon.utils.CommonOperateUtils
import com.easpeed.elevator.ui.MainActivity
import com.easpeed.elevator.ui.OTDROpticTestingActivity
import com.easpeed.elevator.ui.OpticTestingActivity
import com.easpeed.elevator.utils.ChartUtil.pdjl

/**
 * Created by bigyu on 2024/11/6 16:50
 * com.easpeed.comon.bean
 */
class AppOperateBean : JsonBean() {


    /**
     *  0 不操作
     *  1 返回上一级
     *  2 跳转到光缆检测页面
     *  3 返回首页
     *  4 OTDR测试页面
     */
    var type: Int = 0


}

fun AppOperateBean.home(): AppOperateBean {
    type = 3
    return this
}

fun AppOperateBean.test(): AppOperateBean {
    type = 2
    return this
}

fun AppOperateBean.otdrTtest(): AppOperateBean {
    type = 4
    return this
}
@Deprecated("use home() instead")
fun AppOperateBean.operateFunc(application: Application?): AppOperateBean {
//    when (type) {
//        1 -> {
//
//        }
//
//        2 -> {
//            val sp = PreferenceManager.getDefaultSharedPreferences(application)
//            val dvsZsl = sp.getString("chanel_1_dvs", "1.467")
//            val otdrZsl = sp.getString("chanel_1_otdr", "1.467")
//
//            val bundle = Bundle()
//            CommonMemoryCache.channelCache.let {
//                bundle.putString("channelName", it.name)
//            }
//
//
//
//            bundle.putString("dvsZsl", dvsZsl)
//            bundle.putString("otdrZsl", otdrZsl)
//            bundle.putString("pdjl", pdjl)
//            bundle.putInt("channelIndex", selectChannel)
//
//            CommonOperateUtils.moveTo(ActivityLifecycleHelper.getCurrentActivity(), OpticTestingActivity::class.java, bundle = Bundle().apply {
//                CommonMemoryCache.channelCache.let {
//                    putString("channelName", it.name)
//                }
//            })
//        }
//
//        3 -> {
//            CommonOperateUtils.moveTo(ActivityLifecycleHelper.getCurrentActivity(), MainActivity::class.java)
//        }
//
//        4 -> {
//            CommonOperateUtils.moveTo(ActivityLifecycleHelper.getCurrentActivity(), OTDROpticTestingActivity::class.java, bundle = Bundle().apply {
//                CommonMemoryCache.channelCache.let {
//                    putString("channelName", it.name)
//                }
//            })
//        }
//    }
    return this
}